package com.ea.eadp.nexus.test.pageDefinition.newconsole;

import org.openqa.selenium.WebDriver;
import org.testng.Assert;


public class AnswerSecurityQuestionPage extends ConsoleBasePage {
    public final static String answerInputBox = "loginSecurityAns";

    public AnswerSecurityQuestionPage(WebDriver driver) {
        super(driver, AnswerSecurityQuestionPage.class, answerInputBox);
    }

    public void enterAnswer(String answer) {
        log.info("Enter Answer:" + answer);
        sendInput(answerInputBox, answer);
        clickBlank("//div[@id='panel-answer-security-question']//span[@class='title']");
        sendControllerKey('A');
    }

    public void validateAnswer(String answer, String errorMessage) {
        log.info("Enter Answer:" + answer);
        sendInput(answerInputBox, answer);
        clickBlank("//div[@id='panel-answer-security-question']//span[@class='title']");
        sendControllerKey('A');
        Assert.assertEquals(getAnswerInvalidError(), errorMessage, "Input not trigger the correct error message");
    }

    public String getAnswerInvalidError() {
        return getElementStringByXPath("//li[@id='security-answer-container']//span[@class='origin-ux-textbox-status-message origin-ux-status-message']");
    }
}
